<template>
  <div class="hblistpage-page">
    
    <CommonHeader leftIcon title="备案指南" />

    <div class="hblistpage-list_content">

    <van-pull-refresh
        v-model="refreshing"
        @refresh="onRefresh"
        loosing-text="释放即可刷新"
        pulling-text="下拉刷新">

      <van-list
          v-model:loading="loading"
          :finished="finished"
          finished-text="没有更多了"
          loading-text="加载中..."
          @load="onLoad">

        <div v-for="(item,index) in listData" :key="index">
          <div class="hblistpage-content" @click="itemClick(item)">
            <div class="hblistpage-list_item">{{ item.title}}</div>
            <div class="hblistpage-list_item2"><img src="@/assets/img/jjt.png"></div>
          </div>
          <div class="hblistpage-page_line"></div>
        </div>
      </van-list>
    </van-pull-refresh>
    </div>
  </div>

</template>

<script setup>
import '@/views/handbook/css/HandbookListPage.css'
import uiUtil from "@/util/UiUtil.js";
import {reactive, onMounted, inject, provide} from "vue";
import { useRouter,useRoute} from 'vue-router';

const router = useRouter();
const  route = useRoute();
////////////////////////////////

const onClickLeft = () => {
  router.back()
}




onMounted(() => {
  // uiUtil.vantHeader2()
})


const itemData=uiUtil.ref({})
provide('itemData',itemData)
const itemClick=(item)=>{
  itemData.value =item
  router.push({
    path:uiUtil.routerPath.HandbookListItemPage,
    query: {data: JSON.stringify(item)}
  })
}

/////////请求/////////////////////////////////////


const pageIndex = uiUtil.ref(1)
var ishttp = true
const listData = uiUtil.ref([]);
const initList = () => {
  pageIndex.value=1
  listData.value=[]
  getList()
}
const getList = () => {
  if (!ishttp) return
  ishttp = false
  //品种：品种名称
  //http://202.127.42.144:60011/api/newarchive//api/seedarchive/test/appHelper/getRichTextList?title=


  uiUtil.http().getObj({
    url: uiUtil.urlPath.getRichTextList+'?title=',
    start: function start() {
      // uiUtil.toastLoading()
      if (refreshing.value) {
        refreshing.value = false;
      }
    },
    succeed: function succeed(res) {
      if (200 != res.code) {
        uiUtil.toastFail(res.msg)
        return
      }
      if (0 == res.data.length) {
        // 如果返回数据为空，表示已加载完成
        finished.value = true;
        return;
      }
      // debugger
      if (res.data.length > 0) {
        listData.value  = (res.data)
        pageIndex.value++
        ishttp=false
        finished.value = true;
      }
    },
    failed: function failed(res) {
      // debugger
      console.log('failed=', res)
      // showFailToast('添加失败')
      uiUtil.toastFail('添加失败')
    },
    finish: function finish() {
      uiUtil.toastClose()
      loading.value = false;
      ishttp = true
    }
  })
};

const loading = uiUtil.ref(false);
const finished = uiUtil.ref(false);
const refreshing = uiUtil.ref(false);
const onLoad = () => {
  getList();
};

const onRefresh = () => {
initList()
};
</script>

<style scoped lang="less">


</style>